package com.example.mysql.rest;

import com.example.mysql.bizz.ILogOperate;
import com.example.mysql.entity.AsyncLog;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping(value = "/api/log")
@Slf4j
public class LogOperateRest {

    @Autowired
    private ILogOperate logOperateBizzImpl;

    @PostMapping("/addLog")
    public String addLog(@RequestBody AsyncLog asyncLog){
        if(asyncLog != null) log.info("异步日志请求保存：{}", asyncLog.getUri());
        AsyncLog retAsyncLog = logOperateBizzImpl.addLog(asyncLog);
        if (retAsyncLog == null) return "fail";
        return "success";
    }

}
